package academic.ui.server.utils;

import java.util.ArrayList;
import java.util.List;

import org.apache.torque.TorqueException;
import org.apache.torque.util.BasePeer;

import torque.generated.City;
import torque.generated.CustomersCityPeer;

import ecommerce.soco.shared.*;

import com.workingdogs.village.DataSetException;

public class GWT_CityHelper {

	
	public static ArrayList<GWT_City> getCities(List<City> records) throws DataSetException {
		ArrayList<GWT_City> cities = new ArrayList<GWT_City>();
		for(City c : records)
		{
			GWT_City city = new GWT_City();
			city.setId(c.getCityId());
			city.setCityName(c.getCityName());
			cities.add(city);
		}
		
		return cities;
		
	}

	public static void saveCity(int customerID, int cityId) throws TorqueException {
		BasePeer.executeStatement("update customers set city_id="+cityId+" where customers_id="+customerID);
	}

}
